import { TableColumnProps } from "ant-design-vue";
import { ref } from "vue";
import { FinancialItem, InvoiceType } from "/@/api/main/financial/models";
import { filterColumns, getLabelByValueFromEnum } from "/@/utils/common";

export function useInvoice(exceptKeys?: string[]) {
  const _columns: TableColumnProps<FinancialItem>[] = [
    {
      title: "发票号码",
      dataIndex: "invoiceNum",
    },
    {
      title: "发票图片",
      dataIndex: "invoiceUrl",
    },
    {
      title: "开票日期",
      dataIndex: "invoicingDate",
    },
    {
      title: "发票类型",
      dataIndex: "invoiceType",
      customRender({ text }) {
        return getLabelByValueFromEnum(text, InvoiceType, "invoiceType");
      },
    },
    {
      title: "发票代码",
      dataIndex: "invoiceCode",
    },
    {
      title: "供应商",
      dataIndex: "supplierId",
    },
    {
      title: "开票金额",
      dataIndex: "invoiceAmount",
    },
    {
      title: "状态",
      dataIndex: "status",
    },
    {
      title: "操作",
      key: "oper",
      fixed: "right",
    },
  ];
  if (exceptKeys) {
    filterColumns(_columns, exceptKeys);
  }
  const columns = ref<TableColumnProps<FinancialItem>[]>(_columns);
  return {
    columns,
  };
}
